/**
 * 评论Item项
 */
import React, { Component } from 'react'
import PropTypes from 'prop-types'

class CommentItem extends Component {
  static propTypes = {
    comment: PropTypes.object.isRequired,
    delComment: PropTypes.func.isRequired,
    index: PropTypes.number.isRequired,
  }

  delete = () => {
    const { comment, delComment, index } = this.props
    console.log('delete')
    if (window.confirm(`确认删除${comment.username}的评论吗？`)) {
      delComment(index)
    }
  }
  render() {
    const { comment } = this.props
    return (
      //   <div>
      //     <h3>CommentItem</h3>
      //   </div>
      <li className="list-group-item">
        <div className="handle">
          <a href="javascript:;" onClick={this.delete}>
            删除
          </a>
          <p className="user">
            <span>{comment.username}</span> <span>说：</span>
          </p>
          <p className="centence">{comment.content}</p>
        </div>
      </li>
    )
  }
}
export default CommentItem
